﻿@model IEnumerable<_PLATFORM.DATA.FITTING_TYPE_ASSET>

<script src="@Url.Content("~/Scripts/jquery.jeditable.mini.js")" type="text/javascript"></script>

@*<script type="text/javascript">
    $(document).ready(function () {
        // Establish DataTables

        var oTable = $("#subTableMgmt").dataTable(
            {
                "bPaginate": false,
                "bLengthChange": false,
                "bFilter": false,
                "bSort": true,
                "bInfo": false,
                "bAutoWidth": true
            }
        );

        // Inline cell edits

        $('.edit').editable('../FittingTypeAsset/Edit');
    });

    //Show / Hide Image Upload Element Name
    
    function showHideImageEditUploader(id) {
        var element = document.getElementById(id);
        $(element).toggle(300);
    }
</script>*@

<h2>@ViewBag.FittingTypeName</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("Index", "FittingTypeAsset", FormMethod.Get, null)) { 
    <h3>Select Fitting Type</h3>
    @Html.DropDownList("FITTING_TYPE_ASSET_ID", "Select One")
    <input type="submit" value="Filter By Fitting Type" />
}

<hr />
<table>
    <tr>
        <th>
            NAME
        </th>
        <th>
            IMAGE
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.NAME)
        </td>
        <td>
            @{
       var imageName = item.IMAGE;
       var path = Url.Content("~/Assets/CategoryImages/" + imageName);
            }
            @Html.Image(path, item.NAME + " image.", new { style = "width:100px;height:75px;" })
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
            @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
        </td>
    </tr>
}

</table>

@*<table id="subTableMgmt" class="display">
    <thead>
        <tr>
            <th>
                NAME
            </th>
            <th>
                IMAGE
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @{var ctr = 0;}
        @foreach (var item in Model)
        {

            using (Html.BeginForm("Edit", "FittingTypeAsset", FormMethod.Post, new { id = "form_" + @ctr.ToString(), enctype = "multipart/form-data" }))
            {
                <tr>
                    <td>
                        @{var _id = @Html.DisplayFor(modelItem => item.FITTING_TYPE_ASSET_ID);}
                        <div class="edit" id="div_edit_{@_id}">@Html.DisplayFor(modelItem => item.NAME)</div>
                        <input type="hidden" value="@_id" id="hidden_{@_id}" name="hidden_{@_id}" />
                    </td>
                    <td>
                        @{
                    var imageName = item.IMAGE;
                    var path = Url.Content("~/Content/User/Images/" + imageName);
                        }
                        <div id="image_{@ctr.ToString()}">@Html.Image(path, item.NAME + " image.", new { style = "width:50px;height:25px;" })</div>
                        <a href="#" class="a_changeImage" onclick="showHideImageEditUploader('div_ImageUpload_{@ctr.ToString()}'); return false;">Add / Modify Image?</a>
                        <div id="div_ImageUpload_{@ctr.ToString()}" style="display:none;">
                            <input name="img_imageUpload_{@ctr.ToString()}" type="file" id="img_imageUpload_{@ctr.ToString()}" value="Upload" />
                            <br />
                            <input type="submit" value="Save" id="btn_submit_{@ctr.ToString()}" name="btn_submit_{@ctr.ToString()}" />
                        </div>
                    </td>
                    <td>
                        @Html.ActionLink("Delete", "Delete", new { id = item.FITTING_TYPE_ASSET_ID })
                    </td>
                </tr>
            }
            { ctr++; }
        }
        @using (Html.BeginForm("Edit", "FittingTypeAsset", FormMethod.Post, new { id = "form_" + @ctr.ToString(), enctype = "multipart/form-data" }))
        {
            <tr>
                <td>
                    @Html.TextBox("New_Asset_Name", null, new { @style = "width:150px;" })
                </td>
                <td>
                    <input name="new_img_imageUpload" type="file" id="new_img_imageUpload" value="Upload" />
                </td>
                <td>
                    <input type="submit" value="Add New" />
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <th>
                NAME
            </th>
            <th>
                IMAGE
            </th>
            <th></th>
        </tr>
    </tfoot>
</table>*@
